package com.mbmed.doctor.medadvice.service;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.mbmed.doctor.commons.mapper.ModelVo;
import com.mbmed.doctor.medadvice.bo.Restin1Bo;
import com.mbmed.doctor.medadvice.mapper.Restin1;

@Path("/restin1")
@Component
public class Restin1Service {

	private static Logger logger = Logger.getLogger(SysparametersService.class);
	
	@Autowired
	private Restin1Bo restin1Bo;
	
	@Context
	Request request;
	
	
	
	
	@GET
	@Path("/adviceundo")
	@Produces({MediaType.APPLICATION_JSON})
    public ModelVo getAdivceJcSysparameters(
    		@QueryParam("uriid") java.lang.String uriid
    		) throws Exception{
		ModelVo modelvo = new ModelVo();
		List<Restin1> list = new ArrayList<Restin1>();
		list = restin1Bo.getAdviceUndo(uriid);
		if(list.size()==0){
			modelvo.setResult("false");
			return modelvo;
		}
		Restin1 restin1= list.get(0);
		if(0==restin1.getTabid()){
			modelvo.setResult("success");
		}
		else{
			modelvo.setResult("false");
		}
    	return modelvo;
	}
	
	@GET
	@Path("/todelrestin")
	@Produces({MediaType.APPLICATION_JSON})
	public ModelVo toDelRestin(
    		@QueryParam("usrcode") java.lang.String usrcode
    		) throws Exception{
		ModelVo modelVo = new ModelVo();
		boolean flag = restin1Bo.toDelRestin(usrcode);
		modelVo.setResult(flag+"");
		return modelVo;
	}
}
